<%@ page import="ghr.day0109.lottery.entity.UserMark" %>
<%@ page import="ghr.day0109.lottery.dao.UserDao" %>
<%@ page import="ghr.day0109.lottery.dao.impl.UserDaoimpl" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: Gong
  Date: 2023/1/9
  Time: 11:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8"/>
    <title>燃油汽车指标摇号系统</title>
    <link rel="stylesheet" href="../../../css/ghr/day0109/index.css" type="text/css">
    <script type="text/javascript" src="../../../js/ghr/day0109/jquery-3.6.3.js"></script>
    <script type="text/javascript" src="../../../js/ghr/day0109/index.js"></script>
    <%--    <script type="text/javascript" src="../../../js/ghr/day0109/addUser.js"></script>--%>
    <%
        //jsp组成部分：jsp小脚本 内置对象 jsp指定 注释
        //在jsp页面中获取后端java程序进行交互
        UserDao userDao = new UserDaoimpl();
        //创建map集合对象，用来存储查询列表的搜索条件参数
        Map<String, Object> map = new HashMap<>();
        String search = request.getAttribute("search") ==null?"":
                String.valueOf(request.getAttribute("search"));

        if (!"".equals(search)){
            map.put("userMarkNo",search);
        }
        //调用查询方法
        List<UserMark> userMarks = userDao.queryChooseMode(map);


    %>
</head>
<body>
<div class="tittle">
    <strong>燃油汽车指标摇号系统</strong>
</div>

<div id="con">
    <button id="add" onclick="location.href ='add.jsp'">添加</button>
    <form action="indexControl.jsp" method="post">
    <input type="text"  placeholder="中签编码" id="check" name="mark">
    <button id="select" type="submit" >搜索</button>
    </form>
    <div id="A">
        <a href="index.jsp">参与摇号用户</a>
        <br>
        <a href="lottery.jsp">摇号</a>
    </div>
    <br>
    <br>

</div>
<div>
    <table id="table" class="last">
        <tr>
            <th>姓名</th>
            <th>中签编码</th>
            <th>持照状态</th>
            <th>手机号码</th>
            <th>开户日期</th>
            <th>操作</th>
        </tr>
        <%
            for (int i = 0; i < userMarks.size(); i++) {
                request.setAttribute("user",userMarks.get(i));
                String status = "";
                if (userMarks.get(i).getStatus() == 0) {
                    status = "未持照";
                } else {
                    status = "已持照";
                }

        %>
        <tr name="userMark" >
            <td name="userName">${user.userName}
            </td>
            <td><%=userMarks.get(i).getMarkNo()%>
            </td>
            <td><%=status%>
            </td>
            <td><%=userMarks.get(i).getPhone()%>
            </td>
            <td><%=userMarks.get(i).getOpenDate()%>
            </td>
            <td>
                <a href="detailsControl.jsp?name=<%=userMarks.get(i).getUserName()%><%=userMarks.get(i).getMarkNo()%>">详情</a>
                <a href="delControl.jsp?name=<%=userMarks.get(i).getUserName()%>" name="del">删除</a>

            </td>
        </tr>
        <%

            }
        %>

    </table>
</div>
</body>
</html>
